package com.nwork.cateye.model;

import android.util.Log;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by Administrator on 2015/3/25.
 */
public class CityModel {
    private String provenceName;
    private String cityName;
    private String cityCode;
    private List<CityModel> cityModelList = new LinkedList<>();


    public void parseJson(JSONObject jsonObject) {
        if (jsonObject != null) {
            try {
                JSONArray jsonArray = jsonObject.getJSONArray("城市代码");
                CityModel cityModel;
                for (int i = 0; i < jsonArray.length(); i++) {

                    JSONObject object = jsonArray.getJSONObject(i);
                    String provenceName = object.getString("省");
                    JSONArray cityArray = object.getJSONArray("市");
                    for (int j = 0; j < cityArray.length(); j++) {
                        cityModel = new CityModel();
                        JSONObject cityObject = cityArray.getJSONObject(j);
                        String cityName = cityObject.getString("市名");
                        String cityCode = cityObject.getString("编码");
                        cityModel.setProvenceName(provenceName);
                        cityModel.setCityName(cityName);
                        cityModel.setCityCode(cityCode);
                        cityModelList.add(cityModel);
                    }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        for (int i = 0; i < cityModelList.size(); i++) {
            CityModel cityModel = cityModelList.get(i);
        }

    }

    public String getProvenceName() {
        return provenceName;
    }

    public void setProvenceName(String provenceName) {
        this.provenceName = provenceName;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public String getCityCode() {
        return cityCode;
    }

    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }

    public List<CityModel> getCityModelList() {
        return cityModelList;
    }
}
